<template>
  <div class="action-btn-wp">
    <el-button type="primary" size="small" @click.stop.prevent="handelClick()" :loading="submiting">确认收货</el-button>
  </div>
</template>

<script>
  import {confirmReceive} from '@/api/afterService';
  import {showMessage} from '@/utils/message';

  export default {
    name: 'actionRepairReceived', /*维修确认收货*/
    props:{
      scope:{
        type:Object,
        default:()=>{},
      },
      scopeId:{
        type:String,
        default:'id'
      },
    },
    data(){
      return {
        submiting:false,
      }
    },
    methods: {
      handelClick()
      {
        let index = this.scope.index,
            row =  this.scope.row,
            rows = this.scope.rows;
        let id = row[this.scopeId];

        this.$confirm('确认收货后将通知用户商品已正式进入维修。', '确认收货？', {
          confirmButtonText: '确认收货',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {

          this.submiting = true;

          let data = {
            serviceOrderId:id,
          };

          confirmReceive(data).then(resp=>{

            showMessage({title:'已收货,该商品将进入维修',type:'success'});

            rows.splice(index,1);

            this.$emit('success');

            this.submiting = false;

          }).catch(err=>{
            this.submiting = false;

          })

        }).catch(() => {

        });

      }
    }
  }
</script>